<template>
    <div>
        <van-nav-bar right-text="帮助" left-arrow @click-left="onClickLeft" @click-right="onClickRight" />
        <div style="display: flex;">
            <img src="../../img/n1.png" alt="" style="width: 90%; margin-left: 5%;">
        </div>
        <van-form @submit="onSubmit">
            <van-cell-group inset>
                <van-field v-model="username" name="username" placeholder="请输入手机号"
                    :rules="[{ pattern: pattern, required: true, message: '请填写正确的手机号' }]" />
            </van-cell-group>
            <div style="margin: 16px;">
                <van-button round block type="primary" native-type="submit">
                    同意协议并获取验证码
                </van-button>
                <div style="display: flex; margin-top: 1.5rem;margin-left: 3rem;">
                    <router-link to="/reg" style="flex: 1;">新用户注册</router-link>
                    <router-link to="/dl" style="flex: 1;">账号密码登录</router-link>
                    <span style="flex: 1;">无法登录</span>
                </div>
            </div>
        </van-form>

    </div>
</template>

<script setup>

import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const route = useRoute()

// import { showToast } from 'vant';
import { ref } from 'vue';
// import { loginApi } from '@/api/api';
const username = ref('');
// const password = ref('');

const onSubmit = () =>{
    router.push('/oorr')
}

// const onSubmit = () => {
//     loginApi(username.value, password.value).then((res) => {
//         console.log(res);
//         if (res.data.code == 0) {
//             showToast(res.data.msg);
//             localStorage.setItem('token', res.data.data.token)
//             localStorage.setItem('username', res.data.data.username)
//             router.push('/')
//         } else {
//             showToast(res.data.msg);
//         }
//     })
// }

let pattern = /^1[3-9]\d{9}$/ 
</script>

<style lang="scss" scoped></style>